package com.ebupt.migu.music.common.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xuhongsong
 * @version 1.0
 * @date 2020/12/15 10:44
 */
public class ListUtil {


    public static List<List<String>> spiltList(List<String> list, int groupSize) {
        int listSize = list.size();
        int keyToken = 0;
        List<List<String>> lists = new ArrayList<>();
        for (int i = 0; i < list.size(); i += groupSize) {
            if (i + groupSize > listSize) {        //作用为toIndex最后没有100条数据则剩余几条newList中就装几条
                groupSize = listSize - i;
            }
            List newList = list.subList(i, i + groupSize);
            lists.add(keyToken, newList);
            keyToken++;
        }
        return lists;
    }


}
